import {
    BaseEntity,
    Entity,
    Column,
    PrimaryGeneratedColumn,
    Index,
    CreateDateColumn,
    UpdateDateColumn
} from 'typeorm'

@Entity()
@Index(['address'])
@Index(['hash'], { unique: true })
@Index(['address', 'hash'], { unique: true })
class Transaction extends BaseEntity {
    @PrimaryGeneratedColumn('increment')
    id: number | undefined

    @CreateDateColumn({type: 'datetime'})
    createdAt: Date = new Date()

    @UpdateDateColumn({type: 'datetime'})
    updatedAt: Date = new Date()

    @Column()
    address: string = ''

    @Column()
    hash: string = ''

    @Column()
    data: string = ''
}

export { Transaction }
